﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using BaMusaSoft.RPS.ViewModel;
using BaMusaSoft.RPS.DataModel;

namespace BaMusaSoft.RPS.View
{
    /// <summary>
    /// Interaction logic for AddCustomerWindow.xaml
    /// </summary>
    public partial class AddCustomerWindow : Window
    {
        public AddCustomerWindow()
        {
            InitializeComponent();
        }
        public AddCustomerWindow(AddCustomerViewModel vm)
            : this()
        {
            this.DataContext = vm;
            this.txtCustomerName.Focus();
        }

        private void OkButtonClick(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;

        }

        private void CancelButtonClick(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void ItemSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ((AddCustomerViewModel)this.DataContext).SelectedCustomer = ((ListBox)sender).SelectedItem as Customer;
        }
    }
}
